"use strict";

var _ = require("lodash");
var mysql = require("../mysqlDB.js");
var table = 'qeeniao.user';

module.exports.getinfo = function(where,fields,cb){
	if(!_.isEmpty(fields)){
		fields.join(',');
	}else{
		fields = '*';
	}

	if(_.isEmpty(where)){
		cb(new Error('Where Condition is Empty!'));
	}else{
		_.forEach(where,function(key,value){
			where += key + ' ' + value.cond + ' ' +value.val;
		});
	}

	var sql = 'SELECT '+fields+' FROM '+table+'  WHERE '+where;
	mysql.query(sql,cb);
};

module.exports.update = function(where,data,cb){
	mysql.query(sql,cb);
};

module.exports.create = function(data,cb){
	mysql.query(sql,values,cb);
};

module.exports.delete = function(where,cb){
	mysql.query(sql,values,cb);
};